<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Child = {
      template: `
        <div>
          <h3>这是子组件</h3>  
          {{a}}
          {{b}}
          {{c}}
          {{d}}
          <button v-for="item in e" :key="item">{{item}}</button>
        </div>
      `,
      props: {
        // 只验证数据类型
        a: String,
        // 只验证数据类型 数据类型可以有多个
        b: [String, Number],
        // 既验证数据类型 还要求必须 传值
        c: {
          type: String,
          required: true
        },
        // 验证数据类型，有默认值
        d: {
          type: Number,
          default: 0
        },
        e: {
          type: Array,
          default: () => [1,2,3]
        }
      },
      mounted(){
        console.log(this);
      }
    }
    const CommonHead = {
      template: `
        <div>
          <h2>这是父组件</h2>  
          <hr/>
          <child a="100" :b="2" c="dwdw"></child>  
        </div>
      `,
      data() {
        return {
          msg: '父组件内部数据'
        }
      },
      components: {
        Child
      }
    }
    Vue.component('CommonHead', CommonHead)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>

</html>